<?php

require_once 'Pipes/FileSystem/Generic/Finder.php';
require_once 'PipesImpl/Config.php';

class Pipes_Model_Mapper_Factory
{
	private $_config = null;
	private $_finder = null;
	
	public function __construct(PipesImpl_Config $config) {
		$this->_config = $config;
		$this->_finder = new Pipes_FileSystem_Generic_Finder($config);
	}
	
	public function factory($name) {
		$className = 'Models_Mappers_' . ucfirst(strtolower($name)) . 'Mapper';
		$this->_finder->find($className)->requireOnce();

		$mapperName = $this->_finder->lastLoaded;
		return new $mapperName($this->_config, new Pipes_Storage($this->_config));
	}
}
